﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace Infov1.Converters
{
    public class BooleanToYesNoConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool boolValue)
            {
                return boolValue ? "是" : "否";
            }
            return "否";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string strValue)
            {
                return strValue == "是";
            }
            return false;
        }
    }
   
   public class BooleanToTextConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool isTrue)
            {
                // 检查是否有参数
                if (parameter is string param)
                {
                    var options = param.Split('|');
                    if (options.Length == 2)
                    {
                        return isTrue ? options[0] : options[1];
                    }
                }
                // 如果没有参数，使用默认值
                return isTrue ? "远程" : "电话";
            }
            return "未知";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}